/*
 * Copyright 2025 arisgo@163.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.arisgo.cloud.flux.mybatis.model;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Coulson
 * @since 2023-7-2
 */
public class NumberIdWithTree<T extends NumberId> extends NumberIdWithTime implements ITree<T> {

    private String parentCode;
    private String code;
    private List<T> children;

    @Override
    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getCode() {
        return this.code;
    }

    @Override
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }

    @Override
    public String getParentCode() {
        return this.parentCode;
    }

    @Override
    public void setChildren(List<T> children) {
        this.children = children;
    }

    @Override
    public List<T> getChildren() {
        return this.children;
    }

    public static final String PARENT_CODE = "parent_code";
    public static final String CODE = "code";
    public static final String CHILDREN = "children";

    public static String[] getDefaultColumnName() {
        List<String> columns = new ArrayList<>(List.of(NumberIdWithTime.getDefaultColumnName()));
        columns.addAll(new ArrayList<>(List.of(PARENT_CODE, CODE, CHILDREN)));
        return columns.toArray(new String[9]);
    }
}
